class Solution {
public:
    int maxHeightOfTriangle(int red, int blue) {
        int tmp1 = red,tmp2 = blue;
        int ret1 = 0,ret2 = 0;
        int i = 1;
        while(1){
            if(tmp1 < i ){
                break;
            }else{
                tmp1 -= i;
                ret1++;
                i++;
            }
            if(tmp2 < i ){
                break;
            }else{
                tmp2 -= i;
                ret1++;
                i++;
            }
        }
         tmp1 = red,tmp2 = blue;
        i = 1;
        while(1){
            if(tmp2 < i ){
                break;
            }else{
                tmp2 -= i;
                ret2++;
                i++;
            }
            if(tmp1 < i ){
                break;
            }else{
                tmp1 -= i;
                ret2++;
                i++;
            }
        }
        cout<<ret1<<' '<<ret2<<' ';
        return max(ret1,ret2);
    }
};